package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.ApprovalProcess;
import com.eling.elcms.travel.service.IApprovalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
public class ApprovalController extends BaseFormController{
	
	@Autowired 
	private IApprovalService approvalService;
	
	@RequestMapping("/api/approval/approval")
	@ResponseBody
	public Map<String, Object> approval(@ModelAttribute@ModelFilling ApprovalProcess approvalProcess) {
	  return approvalService.approval(approvalProcess);
	}
	
	@RequestMapping("/api/approval/approvalTest")
	@ResponseBody
	public BaseModel save(@RequestParam("modelId") Long modelId,@RequestParam("modelClass") String modelClass) {
	  return approvalService.approvalTest(modelId,modelClass);
	}
}
